<?php

function ecommerceBuildRoute(&$query)
{	//$query['Itemid']=20;
	$segments = array();
	
	unset($query['view']);
	if(isset($query['parent']))
	{
		$segments[] = $query['parent'];
		unset($query['parent']);
		
	}
	if(isset($query['catid']))
	{
		$segments[] = $query['catid'];
		unset($query['catid']);
		
	}
	
	
	return $segments;
}

function ecommerceParseRoute($segments)
{
	//print_r($segments); die();
	$vars = array();
	
	$catid = intval($segments[1]);
	$parent = intval($segments[0]);

	if($catid) {
		 $vars['catid'] = $catid;
		 $vars['parent'] = $parent;
		 $vars['view'] = "list";
	} else if($parent){
		$vars['catid'] = $parent;
		$vars['view'] = "category";
	}	 
	
	return $vars;
}
?>